class AdminController < ApplicationController
  def login
    session[:boss_id] = nil
    if request.post?
      boss = Boss.authenticate(params[:name], params[:password])
      if boss
        session[:boss_id] = boss.id
        uri = session[:original_uri]
        session[:original_uri] = nil
        redirect_to(uri || { :action => "index" })
      else
        flash.now[:notice] = "Combinação login/senha inválida."
      end
    end
  end

  def logout
    session[:user_id] = nil
    flash[:notice] = "Logout realizado com sucesso."
    redirect_to(:action => "login" )
  end

  def index
    @total_rentals = Rental.count
  end

end
